namespace NhibernateDemoCore
{
    public class OrderLine
    {
        public virtual string Product { get; private set; }
        public virtual int Quantity { get; set; }

        protected OrderLine()
        {
        }

        public OrderLine(string product)
        {
            Product = product;
        }

        public virtual bool Equals(OrderLine other)
        {
            if (ReferenceEquals(null, other)) return false;
            return ReferenceEquals(this, other) || Equals(other.Product, Product);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return obj.GetType() == typeof (OrderLine) && Equals((OrderLine) obj);
        }

        public override int GetHashCode()
        {
            return Product.GetHashCode();
        }

        public static bool operator ==(OrderLine left, OrderLine right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(OrderLine left, OrderLine right)
        {
            return !Equals(left, right);
        }
    }
}